using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data {
	public class MerchantPaymentMap : EntityTypeConfiguration<MerchantPayment> {
		public MerchantPaymentMap() {
			// table
			ToTable("mc_MerchantPayment", "dbo");

			// keys
			HasKey(t => t.Id);

			// Properties
			Property(t => t.Id)
				.HasColumnName("Id")
				.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
				.IsRequired();
			Property(t => t.PaymentId)
				.HasColumnName("PaymentId")
				.IsRequired();

			// Relationships
			HasOptional(t => t.Merchant)
				.WithMany()
				.HasForeignKey(d => d.MerchantId)
				.WillCascadeOnDelete(false);
			//HasOptional(t => t.Grade)
			//	.WithMany(t => t.MerchantPayments)
			//	.HasForeignKey(d => d.GradeId)
			//	.WillCascadeOnDelete(false);
			HasRequired(t => t.Payment)
				.WithMany()
				.HasForeignKey(d => d.PaymentId)
				.WillCascadeOnDelete(false);
		}
	}
}
